package com.ruibang.glass.produce.service.impl;

import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruibang.glass.produce.domain.resp.MonitorRuleInfo;
import com.ruibang.glass.produce.domain.resp.MonitorRuleResp;
import com.ruibang.glass.produce.entity.MonitorRule;
import com.ruibang.glass.produce.mapper.MonitorRuleMapper;
import com.ruibang.glass.produce.service.MonitorRuleService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;


/**
 * @Author: songJinKang
 * @CreateTime: 2023-11-20  19:28
 * @Description: TODO
 * @Version: 1.0
 */
@Slf4j
@Service
public class MonitorRuleServiceImpl extends ServiceImpl<MonitorRuleMapper, MonitorRule> implements MonitorRuleService {

    @Override
    public void removeByDeviceId(String deviceId) {
        this.remove(lambdaQuery().eq(MonitorRule::getDeviceId, deviceId).getWrapper());
    }

    @Override
    public List<MonitorRuleResp> getRuleByMonitorId(List<String> monitorIds) {
        if (CollectionUtils.isNotEmpty(monitorIds)) {
            return baseMapper.getRuleByMonitorId(monitorIds);
        }
        return Collections.emptyList();
    }

    @Override
    public List<MonitorRuleInfo> getMonitorRuleInfoByMonitorId(String monitorId) {
        if (StringUtils.isNotEmpty(monitorId)) {
            return baseMapper.getMonitorRuleInfoByMonitorId(monitorId);
        }
        return Collections.emptyList();
    }


}
